package com.geek.javase.wcy02;

/**
 * @author wangchaoyang
 * @desc TODO
 * @date 2025/9/2
 */

import java.util.Scanner;
public class ForDemo1 {
    public static void main(String[] args) {
        int randomNum = (int) (Math.random() * 100) + 1;
        Scanner scanner = new Scanner(System.in);
        for (int count = 1; count <= 7; count++) {
            System.out.print("请输入一个1-100的数字：");
            int guess = scanner.nextInt();

            if (guess == randomNum) {
                System.out.println("恭喜你猜对了！");
                break;
            } else if (guess < randomNum) {
                System.out.println("太小了，再大一点！");
            } else {
                System.out.println("太大了，再小一点！");
            }
            // 若7次都没猜对，循环结束后输出提示
            if (count == 7) {
                System.out.println("你太笨了，下次再来吧！");
            }
        }
    }
}
